<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('短链接列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="short:third:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="short:third:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="short:third:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('short:third:edit')}]];
        var removeFlag = [[${@permission.hasPermi('short:third:remove')}]];
        var prefix = ctx + "short/third";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "第三方接口",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'name', 
                    title: '接口名称',
                    visible: true
                },
                {
                    field: 'api', 
                    title: 'api地址',
                    formatter: function(value, row, index) {
                        if(value.length>15){
                        	return "<span title='"+value+"'>"+value.substring(0,15)+"...</span>";
                        }
                        return value;
                    }
                },
                {
                    field: 'param', 
                    title: '参数',
                    formatter: function(value, row, index) {
                        if(value.length>15){
                            return "<span title='"+value+"'>"+value.substring(0,15)+"...</span>";
                        }
                        return value;
                    }
                },
                {
                    field: 'urlencode', 
                    title: '参数是否使用url编码',
                    visible: true,
                    formatter: function(value, row, index) {
                        return value?"是":"否";
                    }
                },
                {
                    field: 'method', 
                    title: '发送方式'
                },
                {
                    field: 'parsekey', 
                    title: '解析json',
                    formatter: function(value, row, index) {
                        return (value==null||value=='')?'直接返回':value;
                    }
                },
                {
                    field: 'useDefault', 
                    title: '默认接口',
                    visible: true,
                    formatter: function(value, row, index) {
                        return value?"是":"-";
                    }
                },
                {
                    field: 'visable', 
                    title: '是否显示',
                    visible: true,
                    formatter: function(value, row, index) {
                        return value?"是":"否";
                    }
                },
                {
                    field: 'sort', 
                    title: '排序',
                    visible: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        
        var validator = $("#formId").validate({
            focusCleanup: true
        });
        
        function formSearch(){
        	if (validator.form()) {
        		$.table.search();
            }
        }
    </script>
</body>
</html>